{{include file="Manage/header.html"}}
<body>
{{include file="Manage/menu.html"}}
<div class="index_main">
    {{include file="Manage/menu2.html"}}
        <div class="prodect">
            <div class="center">
                <div class="year">
                    <div>
                        <span>项目申报时间</span>
                        <select id="year">
                            <option value="{{$project.now_year}}" selected="true">{{$project.now_year}}年</option>
                            {{if $project.years}}
                            {{foreach from=$project.years item=val}}
                                {{foreach from=$val item=val2}}
                                {{if $project.now_year != $val2}}
                            <option value="{{$val2}}" {{if $val2 == $smarty.get.year}}selected="true"{{elseif $val2 == $project.now_year}}selected="true"{{/if}}>{{$val2}}年</option>
                                {{/if}}
                                {{/foreach}}
                            {{/foreach}}
                            {{/if}}
                        </select>
                    </div>
                </div>
                {{if !$project.id}}
                <div class="build">
                    <a  href="index.php?app=Myproject&act=detail">
                        <span>今年未申请任何，请先创建项目或者右上角查看往年项目</span>
                    </a>
                </div>
                {{else}}
                <div class="project">
                    <div class="pro">
                        <div class="brief">
                            <div class="state"><span>{{if $project.auditing_1 == '0'}}院系未审核{{elseif $project.auditing_1 == '1'}}院系审核通过{{elseif $project.auditing_1 == '2'}}院系审核不通过{{/if}}</br>{{if $project.auditing_1 == '0'}}cxcyxy未审核{{elseif $project.auditing_1 == '1'}}cxcyxy审核通过{{elseif $project.auditing_1 == '2'}}cxcyxy审核不通过{{/if}}</span></div>
                            <div class="name">
                                <a  href="index.php?app=Myproject&act=detail&id={{$project.id}}">
                                    {{$project.project}}
                                    <span>项目创始人：{{$result.username}}</span>
                                </a>
                            </div>
                            <div class="op">
                                <a  href="index.php?app=Myproject&act=detail&id={{$project.id}}{{if $smarty.get.year}}&year={{$smarty.get.year}}{{/if}}">编辑</a>
                                <a  href="#del_project" class="delete_p">删除</a>
                            </div>
                        </div>
                        <div class="detail">
                            <div>项目介绍</div>
                            <p>
                                {{$project.params.descride}}
                            </p>
                        </div>
                    </div>
                    <div class="member">
                        <div class="title">——&nbsp;&nbsp;团队成员&nbsp;&nbsp;——</div>
                        <div class="add_button"><a  id="add1" href="#add_member"></a></div>
                        <ul>
                            <li>
                                <span>{{$result.username}}</span>
                                <p>团队角色：项目创始人</p>
                            </li>
                            {{if $project.members.student}}
                            {{foreach from=$project.members.student item=val key=key}}
                                <li>
                                    <span>{{$val.0}}</span>
                                    <p>团队角色：团队成员</p>
                                    <div>
                                       <a href="#delete" class="del"><img src="{{$smarty.const.__APP__}}/manage/images/delete.png" class="delete_member" onclick="delete_member({{$key}}{{if $smarty.get.year}},{{$smarty.get.year}}{{/if}})"></a>
                                    </div>
                                </li>
                            {{/foreach}}
                            {{/if}}
                        </ul>
                    </div>
                    <div class="teacher">
                        <div class="title">——&nbsp;&nbsp;指导老师&nbsp;&nbsp;——</div>
                        <div class="add_button"><a  id="add2" href="#add_teacher"></a></div>
                        {{if $project.members.teacher}}
                        <ul>
                            <li>
                                <span>{{$project.members.teacher.username}}</span>
                                <p>导师职称：{{$project.members.teacher.professional}}</p>
                                <div>
                                    <a href="#delete" class="del"><img src="{{$smarty.const.__APP__}}/manage/images/delete.png" class="delete_member" onclick="delete_member('-1'{{if $smarty.get.year}},{{$smarty.get.year}}{{/if}})"></a>
                                </div>
                            </li>
                        </ul>
                        {{/if}}
                    </div>
                    <div class="schedule">
                        <div class="title">——&nbsp;&nbsp;项目进程&nbsp;&nbsp;——</div>
                        <div class="flow">
                            <div></div>
                            <span>START</span>
                            <span>步骤二</span>
                            <!--<span>步骤三</span>-->
                            <!--<span>步骤四</span>-->
                            <!--<span>ENDING</span>-->
                        </div>
                    </div>
                </div>
                {{/if}}
            </div>
        </div>
    </div>
</div>
<!-- 弹窗：添加团队成员 -->
<div style='display:none;'>
    <div id='add_member'>
        <div class="title">添加团队成员</div>
        <form method="post" onsubmit="return false" id="student">
            <input type="hidden" name="type" value="student">
            <input type="hidden" name="year" value="{{if $smarty.get.year}}{{$smarty.get.year}}{{/if}}">
            <div>
                <p class="error" style='display:none;'></p>
                <div class="inform">
                    <span>*</span>真实姓名:
                    <input type="text" name="username" placeholder="团队成员的真实姓名">
                </div>
                <div class="inform">
                    <span>*</span>手机号码:
                    <input type="text" name="number" placeholder="请输入团队成员的手机号码">
                </div>
                <p class="warm1 student"></p>
                <div>
                    <button type="submit" onclick="add('student')">确定</button>
                    <button type="reset">取消</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 弹窗：添加指导老师 -->
<div style='display:none;'>
    <div id='add_teacher'>
        <div class="title">添加指导老师</div>
        <form method="post" onsubmit="return false" id="teacher2">
            <input type="hidden" name="type" value="teacher">
            <input type="hidden" name="year" value="{{if $smarty.get.year}}{{$smarty.get.year}}{{/if}}">
            <div>
                <p class="error" style='display:none;'></p>
                <div class="inform">
                    <span>*</span>真实名称:
                    <input type="text" name="username" placeholder="指导老师的真实名称" value="{{if $project.members.teacher.username}}{{$project.members.teacher.username}}{{/if}}">
                </div>
                <div class="inform">
                    <span>*</span>手机号码:
                    <input type="text" name="number" placeholder="请输入指导老师的手机号码" value="{{if $project.members.teacher.number}}{{$project.members.teacher.number}}{{/if}}">
                </div>
                <div class="inform">
                    <span>*</span>电子邮箱:
                    <input type="text" name="email" placeholder="请填写电子邮箱" value="{{if $project.members.teacher.email}}{{$project.members.teacher.email}}{{/if}}">
                </div>
                <div class="inform">
                    <span>*</span>所在院校:
                    <!--<input type="text" name="" placeholder="请选择所在院校">-->
                    <select name="college">
                        <option value="">请现在所在院系</option>
                        {{foreach from=$result.colleges item=val key=key}}
                        <option value="{{$val.title}}" {{if $val.title == $project.members.teacher.college}}selected="selected"{{/if}}>{{$val.title}}</option>
                        {{/foreach}}
                    </select>
                </div>
                <div class="inform">
                    <span>*</span>导师职称:
                    <input type="text" name="professional" placeholder="请填写项目导师职称..." value="{{if $project.members.teacher.professional}}{{$project.members.teacher.professional}}{{/if}}">
                </div>
                <p class="warm2 teacher2">!用户姓名不能为空</p>
                <div>
                    <button type="submit" onclick="add('teacher2')">确定</button>
                    <button type="reset">取消</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 弹窗：删除成员 -->
<div style='display:none;'>
    <div id='delete'>
        <div class="title">删除团队成员</div>
        <p>?  确认删除该成员身份</p>
        <div>
            <button type="submit" onclick="delete_member2()" id="data">确定</button>
            <button type="reset">取消</button>
        </div>
    </div>
</div>
<!-- 弹窗：删除成项目 -->
<div style='display:none;'>
    <div id='del_project'>
        <div class="title">删除项目</div>
        <p>?  确认删除该项目</p>
        <div>
            <button type="submit" onclick="delete_project({{$project.id}}{{if $smarty.get.year}},{{$smarty.get.year}}{{/if}})">确定</button>
            <button type="reset">取消</button>
        </div>
    </div>
</div>
<script>
    $(function(){

        $("#add1").colorbox({inline:true, width:"500px",opacity:0.6});
        $("#add2").colorbox({inline:true, width:"500px",opacity:0.6});
        $(".delete_p").colorbox({inline:true, width:"500px",opacity:0.6});
    });

    $("#year").change(function(){
        var url = "{{$smarty.server.REQUEST_URI}}";
        var year = $(this).val();
        url = setURLArg(url,'year',year);
        document.location.href = url;
    })

    //删除项目
    function delete_project(id,year){
        $.post('{{"index.php?app=Myproject&act=delete_project"|URL}}',{'id':id,'year':year},function(result){
            result_m(result);
        },'json');
    }

    //删除成员
    function delete_member(id,year){
        $(".del").colorbox({inline:true, width:"500px",opacity:0.6});
        $("#delete").attr("id1",id,"year",year);
    }
    function delete_member2() {
        var id = $("#delete").attr('id1');
        var year = $("#delete").attr('year');
        $.post('{{"index.php?app=Myproject&act=delete_member"|URL}}',{'id':id,'year':year},function(result){
            result_m(result);
        },'json');
    }

    //添加成员
    function add(type){
        var params = $("#"+type+"").serialize();
        $.post('{{"index.php?app=Myproject&act=add"|URL}}',params,function(result){
            result_m(result,type);
        },'json');
    }

    //
    function result_m(result,type){
        if(result.statusCode=='200'){
            ui.success(result.message);
            setTimeout(function(){
                location.reload();
            },1000);
        }else if(result.statusCode=='300') $("."+type).show().html(result.message);
    }
</script>
{{include file="Manage/footer.html"}}
